<nz-card>
  <div class="common-search-wrap">
    <div class="common-search-forms">
      <div class="common-form-item">
        <label class="common-search-label">注册手机号</label>
        <div class="common-search-conrol">
          <input nz-input placeholder="请输入注册手机号" [(ngModel)]="searchParams.phone" />
        </div>
      </div>

      <div class="common-form-item">
        <label class="common-search-label">状态</label>
        <div class="common-search-conrol">
          <nz-select
            [nzMaxTagCount]="1"
            nzMode="multiple"
            nzAllowClear
            nzPlaceHolder="请选择状态"
            [(ngModel)]="searchParams.statusList"
          >
            <nz-option *ngFor="let item of stateOptions" [nzLabel]="item.label" [nzValue]="item.value"></nz-option>
          </nz-select>
        </div>
      </div>

      <div class="common-form-item">
        <label class="common-search-label">联系人</label>
        <div class="common-search-conrol">
          <input nz-input placeholder="姓名/手机号/邮箱" [(ngModel)]="searchParams.contactsName" />
        </div>
      </div>

      <div class="common-form-item">
        <label class="common-search-label">公司名</label>
        <div class="common-search-conrol">
          <input nz-input placeholder="请输入公司名" [(ngModel)]="searchParams.companyName" />
        </div>
      </div>

      <div class="common-form-item">
        <label class="common-search-label">申请时间</label>
        <div class="common-search-conrol">
          <nz-range-picker [(ngModel)]="applyDates" (ngModelChange)="timeChange($event)"></nz-range-picker>
        </div>
      </div>

      <div class="common-form-item">
        <div class="common-search-conrol">
          <button nz-button nzType="primary" class="m-r-8" [nzLoading]="tableParams.tableLoading" (click)="searchData()">查询</button>
          <button nz-button nzType="default" (click)="resetData()">重置</button>
        </div>
      </div>
    </div>
  </div>
</nz-card>

<nz-card class="m-t-2">
  <div class="pagination-wrap-position table-wrap">
    <nz-table
      #basicTable
      nzSize="small"
      nzShowSizeChanger
      nzShowQuickJumper
      nzOuterBordered
      [nzScroll]="{ x: '1100px' }"
      [nzFrontPagination]="false"
      [nzLoadingDelay]="100"
      [nzLoading]="tableParams.tableLoading"
      [nzData]="tableData"
      [nzPageSizeOptions]="[5, 10, 20, 50, 100]"
      [nzTotal]="tableParams.total"
      [nzPageIndex]="tableParams.page"
      [nzPageSize]="tableParams.pageSize"
      [nzShowTotal]="totalTemplate"
      (nzPageIndexChange)="onPageIndexChange($event)"
      (nzPageSizeChange)="onPageSizeChange($event)"
    >
      <thead>
        <tr>
          <th nzAlign="center" nzWidth="160px">手机号</th>
          <th nzAlign="center" nzWidth="150px">状态</th>
          <th nzAlign="center" nzWidth="150px">已申请代理</th>
          <th nzAlign="center" nzWidth="150px">已成功代理</th>
          <th nzAlign="center" nzWidth="150px">联系人</th>
          <th nzAlign="center" nzWidth="160px">联系人手机号</th>
          <th nzAlign="center" nzWidth="180px">联系人邮箱</th>
          <th nzAlign="center" nzWidth="200px">公司名</th>
          <th nzAlign="center" nzWidth="170px">申请时间</th>
          <th nzAlign="center" nzWidth="170px">最后审核时间</th>
          <th nzAlign="center" nzWidth="180px" nzRight>操作</th>
        </tr>
      </thead>

      <tbody>
        <tr *ngFor="let data of basicTable.data; let index = index;">
          <!-- 手机号 -->
          <td nzAlign="center">{{ data.phone || '-' }}</td>
          <!-- 状态 -->
          <td nzAlign="center">
            <span [ngStyle]="{'color': data.status | advertisementStatus: 'color'}">
              {{ data.status | advertisementStatus: 'label' }}
            </span>
            <i
              *ngIf="data.status == 3"
              nz-icon
              nzType="exclamation-circle"
              nzTheme="outline"
              nz-tooltip
              [nzTooltipTitle]="data.auditOpinion">
            </i>
          </td>
          <!-- 已申请代理 -->
          <td nzAlign="center">{{ data.pendingCount || '0' }}</td>
          <!-- 已成功代理 -->
          <td nzAlign="center">{{ data.agentCount || '0' }}</td>
          <!-- 联系人 -->
          <td nzAlign="center">{{ data.contactsName || '-' }}</td>
          <!-- 联系人手机号 -->
          <td nzAlign="center">{{ data.contactsPhone || '-' }}</td>
          <!-- 联系人邮箱 -->
          <td nzAlign="center">{{ data.contactsEmail || '-' }}</td>
          <!-- 公司名 -->
          <td nzAlign="center">{{ data.companyName || '-' }}</td>
          <!-- 申请时间 -->
          <td nzAlign="center">{{ data.applicationTime || '-' }}</td>
          <!-- 最后审核时间 -->
          <td nzAlign="center">{{ data.auditTime || '-' }}</td>
          <!-- 操作 -->
          <td nzAlign="center" nzRight>
            <button nz-button nzType="link" (click)="showDetailModal(data)">详情</button>
            <button nz-button nzType="link" *ngIf="data.status == 1" (click)="showExamineModal(data)">审核</button>
          </td>
        </tr>
      </tbody>
    </nz-table>

    <!-- 分页template -->
    <ng-template #totalTemplate let-total>共有 {{ tableParams.total }} 条</ng-template>
  </div>
</nz-card>

<!-- S 审核 Modal -->
<nz-modal
  nzClassName="custom-model-wrap"
  [nzFooter]="null"
  [(nzVisible)]="isExamineVisible"
  nzTitle="审核"
  (nzOnCancel)="handleCancel()">

  <div *nzModalContent>
    <div class="custom-model-body">
      <!-- S body -->
      <p class="examin-tip">如果审核不通过，该审核意见会被用户直接看到，请谨慎填写!</p>
      <nz-textarea-count [nzMaxCharacterCount]="150">
        <textarea rows="4" nz-input maxlength="150" [(ngModel)]="auditOpinion" placeholder="请输入审核意见"></textarea>
      </nz-textarea-count>
      <!-- E body -->
    </div>

    <div class="custom-model-foot">
      <div class="custom-foot-cont">
        <button nz-button nzType="primary" (click)="examineSubmit(2)">通过</button>
        <button nz-button nzType="default" nzDanger (click)="examineSubmit(3)">不通过</button>
      </div>
    </div>
  </div>
</nz-modal>
<!-- E 审核 Modal -->

<!-- S 详细信息 -->
<nz-modal
  [nzFooter]="null"
  [(nzVisible)]="isInfoVisible"
  nzTitle="详细信息"
  (nzOnCancel)="isInfoVisible = false">

  <div *nzModalContent>
    <nz-descriptions nzTitle="注册信息" [nzColumn]="1">
      <nz-descriptions-item nzTitle="注册手机号">{{ detailData?.phone || '-' }}</nz-descriptions-item>
    </nz-descriptions>

    <nz-descriptions nzTitle="公司信息" [nzColumn]="1" class="p-t-10">
      <nz-descriptions-item nzTitle="公司名称">{{ detailData?.companyName || '-' }}</nz-descriptions-item>
      <nz-descriptions-item nzTitle="公司地址">{{ detailData?.companyAddress || '-' }}</nz-descriptions-item>
      <nz-descriptions-item nzTitle="法人姓名">{{ detailData?.juridicalPerson || '-' }}</nz-descriptions-item>
      <nz-descriptions-item nzTitle="法人身份证号">{{ detailData?.juridicalIdcard || '-' }}</nz-descriptions-item>
      <nz-descriptions-item nzTitle="法人身份证正面">
        <div class="modal-img-wrap">
          <img
            nz-image
            [nzSrc]="detailData?.juridicalIdcardImgFrontTemp || fallback"
            alt="法人身份证正面"
          />
        </div>
      </nz-descriptions-item>
      <nz-descriptions-item nzTitle="法人身份证反面">
        <div class="modal-img-wrap">
          <img
            nz-image
            [nzSrc]="detailData?.juridicalIdcardImgBackTemp || fallback"
            alt="法人身份证反面"
          />
        </div>
      </nz-descriptions-item>
      <nz-descriptions-item nzTitle="组织机构代码">{{ detailData?.uscc || '-' }}</nz-descriptions-item>
      <nz-descriptions-item nzTitle="组织机构图片">
        <ul class="mechanism-ul">
          <li>
            <img
              nz-image
              [nzSrc]="detailData?.usccImgTemp || fallback"
              alt="组织机构图片"
            />
          </li>
        </ul>
      </nz-descriptions-item>
    </nz-descriptions>

    <nz-descriptions nzTitle="联系人信息" [nzColumn]="1" class="p-t-10">
      <nz-descriptions-item nzTitle="联系人">{{ detailData?.contactsName || '-' }}</nz-descriptions-item>
      <nz-descriptions-item nzTitle="联系方式">{{ detailData?.contactsPhone || '-' }}</nz-descriptions-item>
      <nz-descriptions-item nzTitle="电子邮箱">{{ detailData?.contactsEmail || '-' }}</nz-descriptions-item>
    </nz-descriptions>
  </div>
</nz-modal>
<!-- E 详细信息 -->